package com.cmrx.model;

import java.util.Properties;

import org.apache.ibatis.plugin.Interceptor;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import com.cmrx.model.fiter.MyFilter;
import com.github.pagehelper.PageHelper;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
@EnableTransactionManagement
@ServletComponentScan
@EnableCaching
@EnableScheduling
@EnableSwagger2
public class XkModelApplication {

	public static void main(String[] args) {
		SpringApplication.run(XkModelApplication.class, args);
	}

	@Bean
	PageHelper pageHelper(){
	    //分页插件
	    PageHelper pageHelper = new PageHelper();
	    Properties properties = new Properties();
	    properties.setProperty("reasonable", "true");
	    properties.setProperty("supportMethodsArguments", "true");
	    properties.setProperty("returnPageInfo", "check");
	    properties.setProperty("params", "count=countSql");
	    pageHelper.setProperties(properties);
	    //添加插件
	    new SqlSessionFactoryBean().setPlugins(new Interceptor[]{pageHelper});
	    return pageHelper;
	}
	
	
	@Bean
	MyFilter myFilter(){
		MyFilter myFilter = new MyFilter();
		return myFilter;
	}

	
}

